/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Graph;


/**
 *
 * @author oliviersputael
 */
public class Edges {
	public Edges (Node n1, Node n2, double w) {
		node1 = n1;
		node2 = n2;
		weight = w;
	}
	
	public Edges (Edges e) {
		node1 = e.getNode1();
		node2 = e.getNode2();
		weight = e.getWeight();
	}
	
	public double getWeight () {
		return weight;
	}
	
	public Node getNode1 () {
		return node1;
	}
	
	public Node getNode2 () {
		return node2;
	}
	
	@Override
	public boolean equals (Object o) {
		Edges e = (Edges)o;
		
		return ((node1.equals(e.getNode1()) && node2.equals(e.getNode2())) ||
				 node2.equals(e.getNode1()) && node1.equals(e.getNode1()));
	}
	
	public boolean contains (Node n) {
		return (node1.equals(n) || node2.equals(n));
	}
	
	public Node getOtherNode (Node n) {
		if (node1.equals(n))
			return node2;
		else
			return node1;
	}
	
	@Override
	public String toString () {
		String toString = "";
		toString = toString + node1.getInstruction().getLabel() + " - " + node2.getInstruction().getLabel();
		/*toString = toString + "EDGE: \n";
		toString = toString + "    > Node 1  :  " + node1.getInstruction().getLabel() + "\n";
		toString = toString + "    > Node 2  :  " + node2.getInstruction().getLabel() + "\n";
		toString = toString + "    > Weight  :  " + weight + "\n";*/
		
		return toString;
	}
	
	private Node node1;
	private Node node2;
	private double weight;
}
